<?php
namespace app\api\controller;

use app\common\controller\Common;
use app\api\model\Auth as AuthModel;
use think\Validate;

class Auth extends Common
{
    public function refresh_token()
    {
        $validate = new Validate([
            'token' => 'require',
            'refresh_token' => 'require',
        ]);
        $data = [
            'token' => trim(input('post.refresh_token')),
            'refresh_token' => trim(request()->header('refresh_token')),
        ];
        if (!$validate->check($data)) {
            error($validate->getError(),403);
        }
        return AuthModel::refresh_token($data['refresh_token'], $data['token']);
    }
}
